home *** CD-ROM | disk | FTP | other *** search
- CHKSEG (Check Segment Structure)
-
- CHKSEG is a utility program which may be used to check the segmentation
- structure of an overlayed program. Basically, this program will tell you which
- procedure calls, in segments other than the root, cause other segments to be
- loaded. Only one level of segmentation is supported in this program although
- the source could be modified to support multiple levels of segmentation. In
- addition, only programs which are written in 'C' are accomodated because of the
- manner in which CHKSEG was written.
-
- CHKSEG should be compiled using the large data model (compact, large, huge)
- with a command line similar to the following:
-
- cl /c /AL chkseg.c
-
- It should then be linked with a stack size of about 32000 bytes. The large
- stack size is required because of the recursive nature of some of the
- procedures within the program.
-
- link/ST:32000 chkseg;
-
- CHKSEG operates in the following manner:
-
- 1. It first asks for and then reads the segmentation directives which you
- would normally give to the MSC link module. That is, if you link a
- program with the following command line:
-
- link/<switch>/... @load
-
- 'load' is the file that CHKSEG would read. The 'load' file would
- normally contain object file names with '+'s in between them and
- parenthesis to indicate segments. The format is exactly as indicated
- in the MSC manual for specifying overlays/segments to link.
-
- 2. CHKSEG then asks for the name of a file on which to write the results
- of it's checking. This file will contain a trace (listing of the
- procedure calling heirarchy) of the procedure calls which result in a
- segment being loaded that is not in the calling heirarchy.
-
- 3. Next, CHKSEG asks for a file template (actually, a path specification
- which usually contains wild characters) which provides all the 'C'
- procedures which are used in the segmented program. If not all of the
- procedures are kept in one directory, there is a chance to specify
- another template. CHKSEG uses this template to build a cross-reference
- table for all the 'C' files/procedures which are involved. An
- assumption is made that the file names for the object files are the
- same as those for the 'C' files except for the extension.
-
- 4. After building all cross-references to the 'C' procedures, CHKSEG will
- ask the user for the maximum call depth to check. This essentially is
- the number of levels of 'who-calls-who' that CHKSEG will go to detect
- procedures which are not in the calling heirarchy. The higher the
- number, the more time it will take CHKSEG to perform checking. A value
- in the range 12-15 is normally O.K.
-
-
- 5. CHKSEG will then begin segment checking. For each procedure in each
- segment, it will determine all the procedures that are called by that
- procedure and check to insure the called procedures are either in the
- same segment or are in the root segment. Files which were not
- specified in the load specification are assumed to be loaded in the
- root (this is what MSC link does). If everything is O.K., CHKSEG then
- goes to the next calling level down (all the procedures which are
- called by the starting procedure) and performs the same analysis on
- them. This can continue for the maximum number of levels indicated in
- 4. above. If a procedure is detected that is not in the calling
- heirarchy, a trace back of procedure calls is written to the file
- indicated in step 2. above.
-
- This program takes a while to run if you have a rather large program that you
- are checking. It is not as smart as it could be in performing checks (e.g., if
- it has checked a procedure A that calls B that calls C, it will check B's
- heirarchy also if it encounters B as the starting procedure). However, I
- didn't bother to enhance it since I only use this program occasionally and the
- time to run it isn't that big of a factor.
-
- A probably better implementation of this program would be to read the object
- files instead of the source files for cross-reference purposes. This would
- allow for any language to be used on the source as long as the object file
- format was the same. I didn't do it that way because it was easier to modify a
- 'C' cross-reference program that I had rather than to write a new object cross-
- reference program. Oh, well.
-
- Any comments, corrections, etc. that you have would be appreciated.
-
- Willard Gersbacher CompuServ ID: [76117,2611]
-
-